package org.wlw.teacher.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wlw.teacher.mapper.DepartmentMapper;
import org.wlw.teacher.models.Department;
import org.wlw.teacher.models.Pager;
import org.wlw.teacher.service.IDepartmentService;

import java.util.List;

@Service
public class DepartmentService implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public void add(Department department) {
        departmentMapper.add(department);
    }

    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Override
    public void delete(int id) {
        departmentMapper.delete(id);
    }

    @Override
    public Department load(int id) {
        return departmentMapper.load(id);
    }

    @Override
    public List<Department> list(Department department) {
        return departmentMapper.list(department);
    }

    @Override
    public Pager<Department> find(Department t) {
        //第一段aop
        List<Department> datas = departmentMapper.find(t);
        int total = departmentMapper.findByCount(t);
        Pager<Department> pager = new Pager<>();
        pager.setData(datas);
        pager.setTotals(total);
        return pager;
    }

    @Override
    public int findByCount(Department t) {
        return 0;
    }
}
